<script lang="ts" setup>
import HomePanel from './home-panel.vue'
import useStore from '@/store';
import { useLazyDate } from '@/utils/hook'
import HomeSkeleton from './home-skeleton.vue';
// import { useIntersectionObserver } from '@vueuse/core'
// import { ref } from 'vue';
const { home } = useStore()
const target = useLazyDate(() => {
  home.getHotList();
})

// useIntersectionObserver(target, ([{ isIntersecting }]) => {
  
//   if(isIntersecting) {
//     home.getHotList()
//   }
// })

</script>
<template>
  <div class="home-new" ref="target" >
    <HomePanel  title="人气推荐" sub-title="人气爆款 不容错过">
      <!-- 面板内容 -->
      <Transition name="fade">   
        <ul v-if="home.hotLitst.length" class="goods-list">
          <li v-for="item in home.hotLitst" :key="item.id">
            <RouterLink to="/">
              <img
                v-lazy="item.picture"
                alt=""
              />
              <p class="name ellipsis">{{ item.title }}</p>
              <p class="desc">{{ item.alt }}</p>
            </RouterLink>
          </li>
        </ul>
        <HomeSkeleton v-else :count="4" />
      </Transition>
    </HomePanel>
  </div>
</template>

<style scoped lang="less">
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    background: #f0f9f4;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
  }
}
</style>